<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/thesame.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/rightCon.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/page.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/popCss.css}" media="all" />
	</head>

	<body class="layui-layout-body">
	<div class="layui-body pad12px">
		<!-- 内容主体区域 -->
		<div class="layui-box-con relative">
			<div class="layui-left-con layui-left-label-con pad12px">
				<div class="border-radius4 bgWhite box-shadows">
					<div class="new-add-box-scroll">
						<nav class="label-nav-con" lay-filter="buildingFilter">
							<!-- <p class="f16px lh40px" style="padding-left: 33px;">全部</p> -->
							<input type="hidden" id="buildingNo" value="" name="">
							<ul class="lh40px f14px">
								<li  style="padding-left:33px" value=""  class="current">全部</li>
								<li th:each="list:${buildingList}" th:value="${list.buildingNo}"  th:text="${list.buildingName}"></li>
							</ul>
						</nav>
					</div>
				</div>
			</div>
			<div class="layui-right-con layui-right-label-con" >
				<div class="border-radius4 bgWhite box-shadows">
					<div class="add-box-scroll">
						<div class="mar25px">
							<div class="pt25px pb25px border-bot1px lh32px overflow">
								<p class="left">姓名：</p>
								<p class="left" style="margin-right: 20px">
									<span class="layui-input-inline" style="width: 200px;">
										<input type="text" id="userNameInput" autocomplete="off" class="layui-input">
									</span>
								</p>
								<p class="left">时间范围：</p>
								<p class="left layui-time-img">
									<span class="layui-input-inline" style="width: 200px;">
										<input type="text" readonly id="startDateInput" class="layui-input time-img test-item">
									</span>
									<span>&nbsp;至&nbsp;</span>
									<span class="layui-input-inline" style="width: 200px;">
										<input type="text" readonly  id="endDateInput" class="layui-input time-img test-item">
									</span>
								</p>
								<p class="left ml40px"><span id="searchButton" class="white border-radius4 bgGreen block pl20px pr20px mr20px cursor">查&nbsp;询</span></p>
							</div>
							<div>
								<div class="lh32px overflow add-btn-input mt20px mb20px">
									<p class="right">
										<span>共有<em class="red fb ml5px mr5px" id="totalNum"></em>条数据</span>
									</p>
								</div>
								<div class="border1px border-radius4 relative table-time">
									<table class="layui-hide" id="test" lay-filter="test"></table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
		<script th:src="@{/static/js/jquery-2.1.3.min.js}"></script>
		<script th:src="@{/static/layui/layui.js}"></script>
		<script>
			//左侧菜单栏
			layui.use(['element', 'table', 'layer', 'laydate'], function() {
				var element = layui.element;
				var table = layui.table;
				var layer = layui.layer;
				var laydate = layui.laydate;
				$("input.test-item").each(function () {
					laydate.render({
						elem: this,
						trigger: 'click',
					});
				})

				//第一个实例
				table.render({
					elem: '#test',
					url: "../wardRound/getRecordList",
					page: true,
					id:"test",
					where:{"startDate":$("input#startDateInput").val(),"endDate":$("input#endDateInput").val(),"userName":$("input#userNameInput").val()},
					request: {
						pageName: 'page'
						,limitName: 'pageSize'
					},
					cols: [
						[ //表头
							{
								field: 'id',
								title: '序号',
								hide:true
							},
							{
								field: 'user_no',
								title: '用户编号',
								hide:true
							},
							{
								type: 'numbers',
								title: '序号',
								fixed: 'left',
								width:80
							}
							, {
								field: 'user_name',
								title: '查房时间',
							}
							, {
								field: 'create_time',
								title: '查房时间',
							}, {
								field: 'create_by',
								title: '操作人',
							}, {
								field: 'operation',
								title: '操作',
								style: 'color:#1C9399',
								fixed: 'right',
								templet: function(res) {
									return "<div class='table-list-btn'><span lay-event='seeReport'>查看报告</span></div>"
								}
							}
						]
					],done:function(res, curr, count){
						$("#totalNum").text(count);
					}
				});

				//侧边栏选中样式
				$('.label-nav-con li').click(function() {
					$(this).addClass('current').siblings().removeClass('current');
					let value = $(this).attr("value");
					if(!value){value = "";}
					table.reload("test", {
						url: "../wardRound/getRecordList",
						where:{"startDate":$("input#startDateInput").val(),"endDate":$("input#endDateInput").val(),"buildingNo":value,"userName":$("input#userNameInput").val()}
					})
				})

				table.on('tool(test)', function(obj){
					let data = obj.data;
					switch(obj.event){
						case 'seeReport':
							openPdf(layer,data);
							break;
					};
				});

				$("span#searchButton").on("click",function (e) {
					let value = $('.label-nav-con li.current').attr("value");
					if(!value){value = "";}
					table.reload("test", {
						url: "../wardRound/getRecordList",
						where:{"startDate":$("input#startDateInput").val(),"endDate":$("input#endDateInput").val(),"buildingNo":value,"userName":$("input#userNameInput").val()}
					})
				})

				function openPdf(layer,d) {
					layer.msg('查房报告生成中...', {
						icon: 16
						,shade: 0.01,
						time:50000000
					});
					$.ajax({
						url:"../wardRound/getPdfInfo",
						type:"post",
						dataType:"json",
						data:{"batchNo":d.id,"userNo":d.user_no},
						success:function (result) {
							if(result.code == 200){
								let data = result.data;
								let html = '<div id="pop-con"><div class="pop-up"><div><div class="pop-title relative overflow mb15px"><span class="ml15px">查房报告</span><p class="right pop-close"><img src="../static/img/close_icon.png" class="block"><p></div><article class="mt20px mb20px"><div class="overflow relative mb20px"><p class="textCenter f16px fb">'+getNotNull(result.title)+'</p><p class="right green cursor" style="right: 0; top: 0;" id="downloadPdf"><img src="../static/img/icon_pdf.png" alt="pdf下载" class="mr5px" style="vertical-align: -6px;">下载</p></div><nav class="f14px lh40px"><ul class="underline"><li class="underline-one"><p><em>部门</em><span>'+getNotNull(data.userInfo.building_name)+'</span></p><p><em>室号</em><span>'+getNotNull(data.userInfo.room_name)+'</span></p><p><em>床号</em><span>'+getNotNull(data.userInfo.bed_name)+'</span></p><p><em>入院日期</em><span>'+getNotNull(data.inspectInfo.in_date)+'</span></p><p><em>住院号</em><span>'+getNotNull(data.inspectInfo.in_no)+'</span></p></li><ul class="overflow"><li class="left"><div><p><em>姓名</em><span>'+getNotNull(data.userInfo.user_name)+'</span></p></div><div><p><em>性别</em><span>'+getNotNull(data.inspectInfo.sex)+'</span></p></div><div><p><em>出生年月</em><span>'+getNotNull(data.userInfo.birth_date)+'</span></p></div><div><p><em>民族</em><span>'+getNotNull(data.inspectInfo.nation)+'</span></p><p><em>籍贯</em><span>'+getNotNull(data.userInfo.native_place)+'</span></p></div></li><li class="right"><div><p><em>护理等级</em><span>'+getNotNull(data.userInfo.nursing_cost_name)+'</span></p></div><div><p><em>职业</em><span>'+getNotNull(data.inspectInfo.job)+'</span></p></div><div><p><em>工作单位</em><span>'+getNotNull(data.inspectInfo.work_place)+'</span></p></div><div><p><em>供病史者</em><span>'+getNotNull(data.inspectInfo.history_info)+'</span></p></div></li></ul><li class="underline-posi"><p class="relative"><em>家庭地址</em><span>'+getNotNull(data.inspectInfo.address)+'</span></p></li><li><div>主诉：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.zhu_su)+'</span></p></div></li><li><div>现病史：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.medical_history)+'</span></p></div></li><li><div>既往史：（曾患疾病、既往体质）：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.disease_info)+'</span></p></div></li><li><div>体格检查：</div><div class="underline-one"><p><em>体温</em><span>'+getNotNull(data.inspectInfo.temperature)+'</span><em>℃</em></p><p><em>脉搏</em><span>'+getNotNull(data.inspectInfo.pulse)+'</span><em>次/分钟</em></p><p><em>呼吸</em><span>'+getNotNull(data.inspectInfo.breath)+'</span><em>次/分钟</em></p><p><em>血压</em><span>'+getNotNull(data.inspectInfo.blood_pressure)+'</span><em>mmhg</em></p></div></li><li><div>一般情况（1.以写慢性体征为主；2.皮肤、淋巴、心肺、腹、四肢活动情况、神经反射情况）：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.inspect_describe)+'</span></p></div></li><li><div>实验室检查：</div><div class="underline-chunk underline-div">';
								if(data.laboratory && data.laboratory.length > 0){
									data.laboratory.forEach(function (v,i) {
										html += '<div><span>'+getNotNull(v.name)+'：'+getNotNull(v.text)+'</span></div>';
									})
								}
								html += '</div></li><li><div>初步诊断：</div><div class="underline-chunk underline-div">';
								if(data.disease && data.disease.length > 0){
									data.disease.forEach(function (v,i) {
										html += '<div><span>'+(i+1)+"、"+getNotNull(v.checkName)+ '</span></div>';
									})
								}
								html += '</div></li><li style="margin-bottom: 30px"><div>诊疗计划：</div><div class="underline-chunk underline-div">\n';

								if(data.treatmentPlanning && data.treatmentPlanning.length > 0){
									data.treatmentPlanning.forEach(function (v,i) {
										html += '<div><span>'+getNotNull(v)+ '</span></div>';
									})
								}
								html += '</div></li><ul class="overflow"><div class="left"><div><p><em>医师签名</em><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p></div></div><div class="right"><div><p><span>'+data.year+'</span><em>年</em><span>'+data.month+'</span><em>月</em><span>'+data.day+'</span><em>日</em></p></div></div></ul></ul></nav></article></div></div></div>';
								layer.closeAll();
								layer.open({
									type: 1,
									title: false, //不显示标题栏
									closeBtn: false,
									area: ['720px', '90%'],
									shade: 0.6,
									id: 'payCons', //设定一个id，防止重复弹出
									btnAlign: 'c',
									moveType: 1, //拖拽模式，0或者1
									shadeClose: true, //设置允许点遮罩关闭
									content: html,
									success: function() {
										//关闭弹层
										$(".pop-close").click(function() {
											layer.closeAll();
										});

										$("p#downloadPdf").on("click",function () {
											window.location.href="../wardRound/createPdf?userNo="+d.user_no+"&batchNo="+d.id;
											layer.closeAll();
										})
									},

								});
							}else{
								layer.msg("生成检查报告失败！");
							}
						}
					})

				}

			});

			function getNotNull(val) {
				if(val && $.trim(val) && val != 'undefined' && val != 'null'){
					return val;
				}else{
					return "";
				}
			}
		</script>
	</body>

</html>
